<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>示例6</title>
    <script>
        let name = '刘工';
        let age = 28;
        let job = '前端工程师';
        //普通写法 
        const employee1 = {
            name: name,
            age: age,
            job: job,
            intro: function () {
                console.log(`我是${this.name}，今年${this.age}岁，岗位是：${this.job}`);
            }
        };
        //简洁写法，属性名和变量名一致时，可以省略属性名 
        const employee2 = {
            name,
            age,
            job,
            intro() {
                console.log(`我是${this.name}，今年${this.age}岁，岗位是：${this.job}`);
            }
        };

        employee1.intro();
        employee2.intro();

        // let name = '刘工';
        // let age = 28;
        // let job = '前端工程师';
        // //普通写法 
        // const employee1 = {
        //     name: name,
        //     age: age,
        //     job: job
        // };
        // //简洁写法，属性名和变量名一致时，可以省略属性名 
        // const employee2 = {
        //     name,
        //     age,
        //     job
        // };
    </script>
</head>

<body></body>

</html>